//
//  LBCDetailNewCell.m
//  Moment
//
//  Created by dllo on 15/11/24.
//  Copyright © 2015年 蓝鸥科技. All rights reserved.
//

#import "LBCDetailNewCell.h"

@interface LBCDetailNewCell ()

@property (nonatomic, retain)UIImageView *headImageView;
@property (nonatomic, retain)UILabel *contentLabel;

@end

@implementation LBCDetailNewCell


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubViews];
    }
    return self;
}

- (void)createSubViews{
    
    _titleLabel = [UILabel new];
    _titleLabel.font = [UIFont boldSystemFontOfSize:20];
    _titleLabel.numberOfLines = 2;
    [self.contentView addSubview:_titleLabel];
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(@20);
        make.top.mas_equalTo(@10);
        make.height.mas_equalTo(@50);
        make.right.mas_equalTo(@-20);
        
    }];
    
    _headImageView = [UIImageView new];
    [self.contentView addSubview:_headImageView];
    [_headImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_titleLabel.mas_bottom).offset(5);
        make.left.equalTo(_titleLabel);
        make.width.mas_equalTo(SCREEN_WIDTH * 0.45);
        make.height.mas_equalTo(@90);
        
    }];
    
    _contentLabel = [UILabel new];
    _contentLabel.font = [UIFont systemFontOfSize:15];
    [_contentLabel setTextColor:[UIColor colorWithRed:0.49 green:0.49 blue:0.49 alpha:1]];
    //调节高度
    _contentLabel.numberOfLines = 3;
    [self.contentView addSubview:_contentLabel];
    [_contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_headImageView.mas_top).offset(2);
        make.bottom.equalTo(_headImageView.mas_bottom).offset(-2);
        make.left.equalTo(_headImageView.mas_right).offset(5);
        make.right.mas_equalTo(@-20);
        
    }];
    
}

-(void)setDetailListCell:(LBCDetailList *)detailListCell{
    _detailListCell = detailListCell;
    self.titleLabel.text = self.detailListCell.title;
    [_headImageView sd_setImageWithURL:[NSURL URLWithString:self.detailListCell.coverimg] placeholderImage:[UIImage imageNamed:ImagePlaceHolder]];
    self.contentLabel.text = self.detailListCell.content;
    // 设置label的行间距
    NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc]initWithString:self.contentLabel.text];;
    NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc]init];
    [paragraphStyle setLineSpacing:15];
    [attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, self.contentLabel.text.length)];
    self.contentLabel.attributedText = attributedString;
    self.contentLabel.lineBreakMode = NSLineBreakByTruncatingTail;

}



- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
